<!-- 用户中心 -->
<template>
  <div>
    <wbc-nav></wbc-nav>
    <div class="container">
      <div class="message-page">
        <h2>我的消息</h2>
        <el-table
          :data="NotificationsVoList"
          border
          style="width: 100%">
          <el-table-column
            v-for="(column, index) in tableColumns"
            :key="index"
            :prop="column.prop"
            :label="column.label"
            :width="column.width">
            <template slot-scope="scope">
              <span v-if="column.prop === 'articleName'">
                  <a class="tcolors-bg" :href="'#/DetailArticle?aid='+scope.id" target="_blank">

                </a>
              </span>
              <span v-if="column.prop === 'createTime'">{{ scope.row[column.prop] | formatDate }}</span>
              <span v-else > <a class="" :href="'#/DetailArticle?aid='+scope.row.articleId" >
                    {{ scope.row[column.prop] }}
              </a>
              </span>
            </template>
          </el-table-column>
          <el-table-column
            label="操作"
            width="120">
            <template slot-scope="scope">
              <el-button
                size="mini"
                @click="markAsRead(scope.$index)">
                标记为已读
              </el-button>
              <el-button
                size="mini"
                type="danger"
                @click="deleteMessage(scope.$index)">
                删除
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      </div>
    </div>
</template>

<script>
import header from '../components/header.vue'
import {getNotifications} from'../api/user.js'

import store from '../store'
import {methods} from "babel-plugin-transform-runtime/lib/definitions";
import ruRU from "element-ui/lib/locale/lang/ru-RU";
export default {
  name: 'Notification',
  data() { //选项 / 数据
    return {
      NotificationsVoList:[],
      tableColumns: [
        { prop: 'articleName', label: '标题', width: '200' },
        { prop: 'content', label: '内容' },
        { prop: 'createTime', label: '时间', width: '180' },
      ]
    }

  },
  created() {
    this.getNotifications()
  },
  methods: { //事件处理器
      getNotifications() {
        getNotifications(1,5).then((res) =>{
         this.NotificationsVoList = res;
        })
      }


    },
  components: { //定义组件
    'wbc-nav':header,
  },
  watch: {
    // 如果路由有变化，会再次执行该方法
    '$route':'routeChange'
  }

}
</script>

<style>
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background-color: red;
  border-radius: 50%;
  margin-right: 5px;
}
.userInfoBox .avatarlist{
  position: relative;
}

.avatar-uploader {
  display: inline-block;
  vertical-align: top;
}
.container {
  padding: 20px; /* 容器内边距 */
}

.message-page {
  margin-top: 20px; /* 调整消息页面与导航栏的间距 */
}
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  width: 120px;
  height: 120px;
}
.avatar-uploader .el-upload:hover {
  border-color: #20a0ff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 120px;
  height: 120px;
  line-height: 120px;
  text-align: center;
  position: absolute;
  top:0;
  left:0;
}
.avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: block;
  object-fit: cover;
}
.gotoEdit{
  font-size: 15px;
  float:right;
  cursor: pointer;
  color:#999;
}
.gotoEdit:hover {
  color:#333;
}
/*个人设置*/
.userInfoBox .leftTitle{
  display: inline-block;
  width:100px;
  padding: 10px 0;
}
.userInfoBox .rightInner{
  display: inline-block;
  max-width: calc(100% - 140px);
  vertical-align: top;
}
.userInfoBox li{
  padding:20px;
  border-bottom: 1px solid #ddd;
}
.userInfoBox li:last-child{
  border-bottom: 1px solid transparent;
}
.userInfoBox  .el-input,.userInfoBox  .el-textarea{
  max-width:300px;
  min-width: 100px;
}

.userInfoBox .el-input__inner{
  border-radius: 4px;
}
.userInfoBox  .el-textarea{
  vertical-align: top;
}
.saveInfobtn{
  margin: 20px 0;
  text-align: center;
}
.saveInfobtn a{
  color:#fff;
  padding:6px 20px;
  margin:5px 10px;
  border-radius: 5px;
  font-size: 14px;
}
.userInfoBox .fa-asterisk{
  color: #DF2050;
}
</style>

